#pragma once
#include <string>
#include <vector>

#include<map>


//下载回调
typedef void(__stdcall* DownloadCallback)(char *buf, int len, void *context);

class HttpRequest
{
public:
	HttpRequest(const std::string& ip, int port);
	~HttpRequest(void);

	// Http GET请求
	int HttpGet(std::string req, DownloadCallback  callback = NULL, void *context = NULL);

	// Http POST请求
	std::string HttpPost(std::string req, std::string data);

	int HttpPutFile(std::string req, std::string filename);

#if 0
	// 合成JSON字符串  string int
	static std::string genJsonString(std::string key, int value);
	// 合成JSON字符串  string  string
	static std::string genJsonString_string(std::map<std::string, std::string>  mapRequest);

	// 分割字符串
	static std::vector<std::string> split(const std::string &s, const std::string &seperator);

	// 根据key从Response获取Header中的内容
	static std::string getHeader(std::string respose, std::string key);
	//curl 发送请求
	//bool SendHttpUrl(std::string URL ,std::string strUrl);
	//解析json 字符串 获取指定返回值
	//static std::string HttpRequest::ParseJsonInfo(const std::string &strJsonInfo);
#endif

private:
	std::string         m_ip;
	int             m_port;
};